/*
 * SPDX-License-Identifier: Apache-2.0
 */

package org.hyperledger.fabric.samples.assettransfer;

import java.util.Objects;

import org.hyperledger.fabric.contract.annotation.DataType;
import org.hyperledger.fabric.contract.annotation.Property;

import com.owlike.genson.annotation.JsonProperty;

@DataType()
public final class Asset {

    @Property()
    private final String assetID;

    @Property()
    private final String rID;       //记录编号

    @Property()
    private final String cId;       //车牌号

    @Property()
    private final String aProvince; //收费省份

    @Property()
    private final float amount;     //收费金额

    @Property()
    private final String aProof;    //收费证据信息

    @Property()
    private final String pStart;    //收费起始地点

    @Property()
    private final String pEnd;      //收费结束地点

    @Property()
    private final int status;       //收费状态,是否异常、误收等

    @Property()
    private final String aStart;      //收费起始时间

    @Property()
    private final String aEnd;        //收费结束时间

    @Property()
    private final String dpNum;     //车辆行驶证

    public String getAssetID() {
        return assetID;
    }

    public String getrID() {
        return rID;
    }

    public String getcId() {
        return cId;
    }

    public String getaProvince() {
        return aProvince;
    }

    public float getAmount() {
        return amount;
    }

    public String getaProof() {
        return aProof;
    }

    public String getpStart() {
        return pStart;
    }

    public String getpEnd() {
        return pEnd;
    }

    public int getStatus() {
        return status;
    }

    public String getaStart() {
        return aStart;
    }

    public String getaEnd() {
        return aEnd;
    }

    public String getDpNum() {
        return dpNum;
    }

    public Asset(@JsonProperty("assetID") final String assetID,
                 @JsonProperty("rID") final String rID,
                 @JsonProperty("cId") final String cId,
                 @JsonProperty("aProvince") final String aProvince,
                 @JsonProperty("amount") final float amount,
                 @JsonProperty("aProof") final String aProof,
                 @JsonProperty("pStart") final String pStart,
                 @JsonProperty("pEnd") final String pEnd,
                 @JsonProperty("status") final int status,
                 @JsonProperty("aStart") final String aStart,
                 @JsonProperty("aEnd") final String aEnd,
                 @JsonProperty("dpNum") final String dpNum) {
        this.assetID = assetID;
        this.rID = rID;
        this.cId = cId;
        this.aProvince = aProvince;
        this.amount = amount;
        this.aProof = aProof;
        this.pStart = pStart;
        this.pEnd = pEnd;
        this.status = status;
        this.aStart = aStart;
        this.aEnd = aEnd;
        this.dpNum = dpNum;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Asset asset = (Asset) o;
        return Float.compare(asset.amount, amount) == 0 && status == asset.status && Objects.equals(assetID, asset.assetID) && Objects.equals(rID, asset.rID) && Objects.equals(cId, asset.cId) && Objects.equals(aProvince, asset.aProvince) && Objects.equals(aProof, asset.aProof) && Objects.equals(pStart, asset.pStart) && Objects.equals(pEnd, asset.pEnd) && Objects.equals(aStart, asset.aStart) && Objects.equals(aEnd, asset.aEnd) && Objects.equals(dpNum, asset.dpNum);
    }

    @Override
    public int hashCode() {
        return Objects.hash(assetID, rID, cId, aProvince, amount, aProof, pStart, pEnd, status, aStart, aEnd, dpNum);
    }

    @Override
    public String toString() {
        return "Asset{"
                +
                "assetID='"
                + assetID
                + '\''
                +
                ", rID='"
                + rID + '\''
                +
                ", cId='"
                + cId
                + '\''
                +
                ", aProvince='"
                + aProvince
                + '\''
                +
                ", amount="
                + amount
                +
                ", aProof='"
                + aProof
                + '\''
                +
                ", pStart='"
                + pStart
                + '\''
                +
                ", pEnd='"
                + pEnd
                + '\''
                +
                ", status="
                + status
                +
                ", aStart="
                + aStart
                +
                ", aEnd="
                + aEnd
                +
                ", dpNum='"
                + dpNum
                + '\''
                +
                '}';
    }
}
